/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Ui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.KeyEvent;
import java.awt.font.TextAttribute;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Map;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JSpinner;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.DefaultTableModel;

/** 
 *
 * @author Esteban
 */
public class VentanaModuloFacturacion extends javax.swing.JFrame {

    /**
     * Creates new form VentanaModuloFacturacion
     */
    public VentanaModuloFacturacion() {
        initComponents();
        initComponents2();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelImagenFacturacion = new org.edisoncor.gui.panel.PanelImage();
        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        panelImagenFacturacion2 = new org.edisoncor.gui.panel.PanelImage();
        panelOpciones = new javax.swing.JTabbedPane();
        panelGenerarFactura = new org.edisoncor.gui.panel.PanelImage();
        panelManejoFactura = new javax.swing.JPanel();
        panelCamposFactura = new javax.swing.JPanel();
        campoReciboNumero = new javax.swing.JTextField();
        reciboNumero = new javax.swing.JLabel();
        astReciboNumero = new javax.swing.JLabel();
        fecha = new javax.swing.JLabel();
        estudiante = new javax.swing.JLabel();
        astEstudiante = new javax.swing.JLabel();
        recibido = new javax.swing.JLabel();
        astRecibido = new javax.swing.JLabel();
        formaPago = new javax.swing.JLabel();
        astFormaPago = new javax.swing.JLabel();
        campoRecibido = new javax.swing.JTextField();
        campoEstudiante = new javax.swing.JLabel();
        campoFecha = new javax.swing.JLabel();
        campoNumeroFormaPago = new javax.swing.JTextField();
        campoMesFactura = new com.toedter.calendar.JMonthChooser();
        campoAnioFactura = new com.toedter.calendar.JYearChooser();
        btnSeleccionarEst = new javax.swing.JButton();
        cajaFormaPago = new javax.swing.JComboBox();
        scrollServicios = new javax.swing.JScrollPane();
        tablaServicios = new javax.swing.JTable();
        btnCancelarFacturar = new javax.swing.JButton();
        btnAgregarFacturar = new javax.swing.JButton();
        panelCobros2 = new javax.swing.JPanel();
        pagoInicial = new javax.swing.JLabel();
        saldo = new javax.swing.JLabel();
        campoPagoInicial = new javax.swing.JTextField();
        campoSaldo = new javax.swing.JLabel();
        astPagoInicial = new javax.swing.JLabel();
        panelCobros = new javax.swing.JPanel();
        sumaTotal = new javax.swing.JLabel();
        rebajoTotalDescuentos = new javax.swing.JLabel();
        totalReal = new javax.swing.JLabel();
        campoSumaTotal = new javax.swing.JLabel();
        campoRebajoTotalDescuentos = new javax.swing.JLabel();
        campoTotalReal = new javax.swing.JLabel();
        btnAyuda = new javax.swing.JButton();
        btnNuevaFactura = new javax.swing.JButton();
        campoHora = new javax.swing.JTextField();
        astEstudiante2 = new javax.swing.JLabel();
        astFormaPago2 = new javax.swing.JLabel();
        astPeriodo = new javax.swing.JLabel();
        panelAnularFactura = new org.edisoncor.gui.panel.PanelImage();
        panelManejoFactura1 = new javax.swing.JPanel();
        panelCamposFactura1 = new javax.swing.JPanel();
        campoReciboNumero1 = new javax.swing.JTextField();
        reciboNumero1 = new javax.swing.JLabel();
        astReciboNumero1 = new javax.swing.JLabel();
        fecha1 = new javax.swing.JLabel();
        estudiante1 = new javax.swing.JLabel();
        astEstudiante1 = new javax.swing.JLabel();
        recibido1 = new javax.swing.JLabel();
        astRecibido1 = new javax.swing.JLabel();
        formaPago1 = new javax.swing.JLabel();
        astFormaPago1 = new javax.swing.JLabel();
        campoRecibido1 = new javax.swing.JTextField();
        campoEstudiante1 = new javax.swing.JLabel();
        campoFecha1 = new javax.swing.JLabel();
        campoNumeroFormaPago1 = new javax.swing.JTextField();
        campoMesFactura1 = new com.toedter.calendar.JMonthChooser();
        campoAnioFactura1 = new com.toedter.calendar.JYearChooser();
        btnSeleccionarEst1 = new javax.swing.JButton();
        cajaFormaPago1 = new javax.swing.JComboBox();
        scrollServicios1 = new javax.swing.JScrollPane();
        tablaServicios1 = new javax.swing.JTable();
        btnCancelarFacturar1 = new javax.swing.JButton();
        btnAgregarFacturar1 = new javax.swing.JButton();
        panelCobros3 = new javax.swing.JPanel();
        pagoInicial1 = new javax.swing.JLabel();
        saldo1 = new javax.swing.JLabel();
        campoPagoInicial1 = new javax.swing.JTextField();
        campoSaldo1 = new javax.swing.JLabel();
        astPagoInicial1 = new javax.swing.JLabel();
        panelCobros1 = new javax.swing.JPanel();
        sumaTotal1 = new javax.swing.JLabel();
        rebajoTotalDescuentos1 = new javax.swing.JLabel();
        totalReal1 = new javax.swing.JLabel();
        campoSumaTotal1 = new javax.swing.JLabel();
        campoRebajoTotalDescuentos1 = new javax.swing.JLabel();
        campoTotalReal1 = new javax.swing.JLabel();
        btnAyuda1 = new javax.swing.JButton();
        btnNuevaFactura1 = new javax.swing.JButton();
        campoHora1 = new javax.swing.JTextField();
        astEstudiante3 = new javax.swing.JLabel();
        astFormaPago3 = new javax.swing.JLabel();
        astPeriodo1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        panelImagenFacturacion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/BarraTituloFinal2.png"))); // NOI18N
        panelImagenFacturacion.setPreferredSize(new java.awt.Dimension(840, 60));

        jLabel2.setBackground(new java.awt.Color(255, 255, 255));
        jLabel2.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("SMAMM 2.1");

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Módulo de Facturación");

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/SignedAs.png"))); // NOI18N

        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("Esteban");

        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("Registrado(a) como:");

        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("Cerrar sesión");
        jLabel6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLabel6MousePressed(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jLabel6MouseExited(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jLabel6MouseEntered(evt);
            }
        });

        javax.swing.GroupLayout panelImagenFacturacionLayout = new javax.swing.GroupLayout(panelImagenFacturacion);
        panelImagenFacturacion.setLayout(panelImagenFacturacionLayout);
        panelImagenFacturacionLayout.setHorizontalGroup(
            panelImagenFacturacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImagenFacturacionLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(172, 172, 172)
                .addComponent(jLabel2)
                .addGap(158, 158, 158)
                .addComponent(jLabel3)
                .addGroup(panelImagenFacturacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelImagenFacturacionLayout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addComponent(jLabel5)
                        .addGap(26, 26, 26)
                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelImagenFacturacionLayout.createSequentialGroup()
                        .addGap(101, 101, 101)
                        .addComponent(jLabel6)))
                .addGap(41, 41, 41))
        );
        panelImagenFacturacionLayout.setVerticalGroup(
            panelImagenFacturacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImagenFacturacionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelImagenFacturacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelImagenFacturacionLayout.createSequentialGroup()
                        .addGroup(panelImagenFacturacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel6)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(panelImagenFacturacionLayout.createSequentialGroup()
                        .addGroup(panelImagenFacturacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel1)
                            .addGroup(panelImagenFacturacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );

        panelImagenFacturacion2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/FondoBlanco.png"))); // NOI18N

        panelOpciones.setFont(new java.awt.Font("Calibri", 1, 14)); // NOI18N
        panelOpciones.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                panelOpcionesStateChanged(evt);
            }
        });

        panelGenerarFactura.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BELOW_TOP, new java.awt.Font("Calibri", 1, 18))); // NOI18N
        panelGenerarFactura.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/fondo_facturacion.png"))); // NOI18N
        panelGenerarFactura.setPreferredSize(new java.awt.Dimension(1255, 558));
        panelGenerarFactura.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        panelManejoFactura.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Facturar servicios de estudiantes", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Calibri", 1, 18))); // NOI18N
        panelManejoFactura.setFont(new java.awt.Font("Calibri", 1, 18)); // NOI18N
        panelManejoFactura.setOpaque(false);
        panelManejoFactura.setPreferredSize(new java.awt.Dimension(1255, 558));

        panelCamposFactura.setBackground(new java.awt.Color(255, 255, 255));
        panelCamposFactura.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 204, 255), 2));
        panelCamposFactura.setOpaque(false);
        panelCamposFactura.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        campoReciboNumero.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        campoReciboNumero.setEnabled(false);
        campoReciboNumero.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                campoReciboNumeroKeyTyped(evt);
            }
        });
        panelCamposFactura.add(campoReciboNumero, new org.netbeans.lib.awtextra.AbsoluteConstraints(163, 17, 330, 22));

        reciboNumero.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        reciboNumero.setText("Recibo N°:");
        panelCamposFactura.add(reciboNumero, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 20, -1, -1));

        astReciboNumero.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astReciboNumero.setToolTipText("Campo obligatorio");
        panelCamposFactura.add(astReciboNumero, new org.netbeans.lib.awtextra.AbsoluteConstraints(77, 13, -1, -1));

        fecha.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        fecha.setText("Fecha:");
        panelCamposFactura.add(fecha, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 46, -1, -1));

        estudiante.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        estudiante.setText("Estudiante:");
        panelCamposFactura.add(estudiante, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 69, -1, 22));

        astEstudiante.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astEstudiante.setToolTipText("Campo obligatorio");
        panelCamposFactura.add(astEstudiante, new org.netbeans.lib.awtextra.AbsoluteConstraints(82, 69, -1, -1));

        recibido.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        recibido.setText("Recibimos de:");
        panelCamposFactura.add(recibido, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 98, -1, 22));

        astRecibido.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astRecibido.setToolTipText("Campo obligatorio");
        panelCamposFactura.add(astRecibido, new org.netbeans.lib.awtextra.AbsoluteConstraints(96, 98, -1, -1));

        formaPago.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        formaPago.setText("Número de");
        panelCamposFactura.add(formaPago, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 121, 120, 22));

        astFormaPago.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astFormaPago.setToolTipText("Campo obligatorio");
        panelCamposFactura.add(astFormaPago, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 120, -1, -1));

        campoRecibido.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        campoRecibido.setEnabled(false);
        campoRecibido.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                campoRecibidoKeyTyped(evt);
            }
        });
        panelCamposFactura.add(campoRecibido, new org.netbeans.lib.awtextra.AbsoluteConstraints(163, 92, 330, 22));

        campoEstudiante.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        panelCamposFactura.add(campoEstudiante, new org.netbeans.lib.awtextra.AbsoluteConstraints(163, 69, 330, 22));

        campoFecha.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        campoFecha.setText("Fecha obtenida desde sistema");
        panelCamposFactura.add(campoFecha, new org.netbeans.lib.awtextra.AbsoluteConstraints(163, 46, 330, 22));

        campoNumeroFormaPago.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        campoNumeroFormaPago.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                campoNumeroFormaPagoKeyTyped(evt);
            }
        });
        panelCamposFactura.add(campoNumeroFormaPago, new org.netbeans.lib.awtextra.AbsoluteConstraints(163, 121, 330, 22));

        campoMesFactura.setEnabled(false);
        campoMesFactura.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        campoMesFactura.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                campoMesFacturaPropertyChange(evt);
            }
        });

        campoAnioFactura.setEnabled(false);
        campoAnioFactura.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                campoAnioFacturaPropertyChange(evt);
            }
        });

        btnSeleccionarEst.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        btnSeleccionarEst.setText("Seleccionar Estudiante");
        btnSeleccionarEst.setEnabled(false);
        btnSeleccionarEst.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnSeleccionarEstMouseClicked(evt);
            }
        });

        cajaFormaPago.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        cajaFormaPago.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Forma de Pago:", "Efectivo", "Cheque", "Depósito", "Tarjeta de Crédito" }));
        cajaFormaPago.setEnabled(false);
        cajaFormaPago.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cajaFormaPagoItemStateChanged(evt);
            }
        });
        cajaFormaPago.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cajaFormaPagoActionPerformed(evt);
            }
        });

        scrollServicios.setBackground(new java.awt.Color(0, 153, 254));
        scrollServicios.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true), "Servicios a cobrar:", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Calibri", 1, 18), new java.awt.Color(255, 255, 255))); // NOI18N

        tablaServicios.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        tablaServicios.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Concepto de", "Profesor", "Modalidad", "Monto"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaServicios.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        tablaServicios.setGridColor(new java.awt.Color(0, 102, 204));
        tablaServicios.getTableHeader().setResizingAllowed(false);
        tablaServicios.getTableHeader().setReorderingAllowed(false);
        scrollServicios.setViewportView(tablaServicios);

        btnCancelarFacturar.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        btnCancelarFacturar.setText("Cancelar");
        btnCancelarFacturar.setEnabled(false);
        btnCancelarFacturar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnCancelarFacturarMouseClicked(evt);
            }
        });

        btnAgregarFacturar.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        btnAgregarFacturar.setText("Agregar Factura");
        btnAgregarFacturar.setEnabled(false);
        btnAgregarFacturar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnAgregarFacturarMouseClicked(evt);
            }
        });
        btnAgregarFacturar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarFacturarActionPerformed(evt);
            }
        });

        panelCobros2.setBackground(new java.awt.Color(255, 255, 255));
        panelCobros2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 204, 255), 2));
        panelCobros2.setOpaque(false);

        pagoInicial.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        pagoInicial.setText("Pago inicial:");

        saldo.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        saldo.setText("Saldo:");

        campoPagoInicial.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        campoPagoInicial.setEnabled(false);
        campoPagoInicial.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                campoPagoInicialKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                campoPagoInicialKeyTyped(evt);
            }
        });

        campoSaldo.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N

        astPagoInicial.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astPagoInicial.setToolTipText("Campo obligatorio");

        javax.swing.GroupLayout panelCobros2Layout = new javax.swing.GroupLayout(panelCobros2);
        panelCobros2.setLayout(panelCobros2Layout);
        panelCobros2Layout.setHorizontalGroup(
            panelCobros2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCobros2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(panelCobros2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(saldo)
                    .addGroup(panelCobros2Layout.createSequentialGroup()
                        .addComponent(pagoInicial)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(astPagoInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(4, 4, 4)
                .addGroup(panelCobros2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(campoPagoInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(campoSaldo, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(185, 185, 185))
        );
        panelCobros2Layout.setVerticalGroup(
            panelCobros2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCobros2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelCobros2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelCobros2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(pagoInicial)
                        .addComponent(campoPagoInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(astPagoInicial))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelCobros2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelCobros2Layout.createSequentialGroup()
                        .addGap(0, 5, Short.MAX_VALUE)
                        .addComponent(saldo))
                    .addComponent(campoSaldo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        panelCobros.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 204, 255), 2));
        panelCobros.setOpaque(false);

        sumaTotal.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        sumaTotal.setText("Suma total:");

        rebajoTotalDescuentos.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        rebajoTotalDescuentos.setText("Descuento total aplicado:");

        totalReal.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        totalReal.setText("Total real a pagar:");

        campoSumaTotal.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N

        campoRebajoTotalDescuentos.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N

        campoTotalReal.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N

        javax.swing.GroupLayout panelCobrosLayout = new javax.swing.GroupLayout(panelCobros);
        panelCobros.setLayout(panelCobrosLayout);
        panelCobrosLayout.setHorizontalGroup(
            panelCobrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCobrosLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(panelCobrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(panelCobrosLayout.createSequentialGroup()
                        .addComponent(sumaTotal)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(campoSumaTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelCobrosLayout.createSequentialGroup()
                        .addComponent(totalReal)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(campoTotalReal, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelCobrosLayout.createSequentialGroup()
                        .addComponent(rebajoTotalDescuentos)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(campoRebajoTotalDescuentos, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(190, 190, 190))
        );
        panelCobrosLayout.setVerticalGroup(
            panelCobrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCobrosLayout.createSequentialGroup()
                .addGroup(panelCobrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sumaTotal)
                    .addComponent(campoSumaTotal))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addGroup(panelCobrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rebajoTotalDescuentos)
                    .addComponent(campoRebajoTotalDescuentos))
                .addGap(18, 18, 18)
                .addGroup(panelCobrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(totalReal)
                    .addComponent(campoTotalReal)))
        );

        btnAyuda.setFont(new java.awt.Font("Calibri", 0, 16)); // NOI18N
        btnAyuda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/ayuda.png"))); // NOI18N
        btnAyuda.setText("Ayuda");
        btnAyuda.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnAyudaMouseClicked(evt);
            }
        });
        btnAyuda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAyudaActionPerformed(evt);
            }
        });

        btnNuevaFactura.setFont(new java.awt.Font("Calibri", 0, 16)); // NOI18N
        btnNuevaFactura.setText("Nueva Factura");

        campoHora.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnNuevaFacturaMouseClicked(evt);
            }
        });

        astEstudiante2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astEstudiante2.setToolTipText("Campo obligatorio");

        astFormaPago2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astFormaPago2.setToolTipText("Campo obligatorio");

        astPeriodo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astPeriodo.setToolTipText("Campo obligatorio");

        javax.swing.GroupLayout panelManejoFacturaLayout = new javax.swing.GroupLayout(panelManejoFactura);
        panelManejoFactura.setLayout(panelManejoFacturaLayout);
        panelManejoFacturaLayout.setHorizontalGroup(
            panelManejoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelManejoFacturaLayout.createSequentialGroup()
                .addGap(67, 67, 67)
                .addGroup(panelManejoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelManejoFacturaLayout.createSequentialGroup()
                        .addComponent(scrollServicios, javax.swing.GroupLayout.PREFERRED_SIZE, 973, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(68, Short.MAX_VALUE))
                    .addGroup(panelManejoFacturaLayout.createSequentialGroup()
                        .addComponent(panelCamposFactura, javax.swing.GroupLayout.PREFERRED_SIZE, 512, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(49, 49, 49)
                        .addGroup(panelManejoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panelManejoFacturaLayout.createSequentialGroup()
                                .addGap(2, 2, 2)
                                .addGroup(panelManejoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(campoMesFactura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(panelManejoFacturaLayout.createSequentialGroup()
                                        .addGap(110, 110, 110)
                                        .addComponent(campoAnioFactura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(astPeriodo))
                            .addGroup(panelManejoFacturaLayout.createSequentialGroup()
                                .addComponent(btnSeleccionarEst)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(astEstudiante2))
                            .addGroup(panelManejoFacturaLayout.createSequentialGroup()
                                .addComponent(cajaFormaPago, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(astFormaPago2)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86, Short.MAX_VALUE)
                        .addGroup(panelManejoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(btnNuevaFactura, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btnAyuda, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(97, 97, 97))))
            .addGroup(panelManejoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelManejoFacturaLayout.createSequentialGroup()
                    .addContainerGap(77, Short.MAX_VALUE)
                    .addComponent(panelCobros, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(63, 63, 63)
                    .addComponent(panelCobros2, javax.swing.GroupLayout.PREFERRED_SIZE, 252, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(74, 74, 74)
                    .addComponent(btnAgregarFacturar)
                    .addGap(26, 26, 26)
                    .addComponent(btnCancelarFacturar, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 83, Short.MAX_VALUE)))
        );
        panelManejoFacturaLayout.setVerticalGroup(
            panelManejoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelManejoFacturaLayout.createSequentialGroup()
                .addGroup(panelManejoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelManejoFacturaLayout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addGroup(panelManejoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(panelManejoFacturaLayout.createSequentialGroup()
                                .addGroup(panelManejoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(campoMesFactura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(campoAnioFactura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(astPeriodo))
                                .addGap(17, 17, 17)
                                .addGroup(panelManejoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(btnSeleccionarEst, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(astEstudiante2))
                                .addGap(13, 13, 13)
                                .addGroup(panelManejoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cajaFormaPago, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(astFormaPago2)))
                            .addGroup(panelManejoFacturaLayout.createSequentialGroup()
                                .addComponent(btnAyuda)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnNuevaFactura, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addGroup(panelManejoFacturaLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(panelCamposFactura, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(scrollServicios, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(129, Short.MAX_VALUE))
            .addGroup(panelManejoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelManejoFacturaLayout.createSequentialGroup()
                    .addContainerGap(386, Short.MAX_VALUE)
                    .addGroup(panelManejoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(panelCobros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(panelCobros2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(panelManejoFacturaLayout.createSequentialGroup()
                            .addGap(21, 21, 21)
                            .addGroup(panelManejoFacturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(btnAgregarFacturar, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(btnCancelarFacturar, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGap(0, 17, Short.MAX_VALUE)))
        );

        panelGenerarFactura.add(panelManejoFactura, new org.netbeans.lib.awtextra.AbsoluteConstraints(65, 18, 1120, 520));

        panelOpciones.addTab("Facturar Servicios", panelGenerarFactura);

        panelAnularFactura.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BELOW_TOP, new java.awt.Font("Calibri", 1, 18))); // NOI18N
        panelAnularFactura.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/fondo_facturacion.png"))); // NOI18N
        panelAnularFactura.setPreferredSize(new java.awt.Dimension(1255, 558));
        panelAnularFactura.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        panelManejoFactura1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Facturar servicios de estudiantes", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Calibri", 1, 18))); // NOI18N
        panelManejoFactura1.setFont(new java.awt.Font("Calibri", 1, 18)); // NOI18N
        panelManejoFactura1.setOpaque(false);
        panelManejoFactura1.setPreferredSize(new java.awt.Dimension(1255, 558));

        panelCamposFactura1.setBackground(new java.awt.Color(255, 255, 255));
        panelCamposFactura1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 204, 255), 2));
        panelCamposFactura1.setOpaque(false);
        panelCamposFactura1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        campoReciboNumero1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        campoReciboNumero1.setEnabled(false);
        campoReciboNumero1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                campoReciboNumero1KeyTyped(evt);
            }
        });
        panelCamposFactura1.add(campoReciboNumero1, new org.netbeans.lib.awtextra.AbsoluteConstraints(163, 17, 330, 22));

        reciboNumero1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        reciboNumero1.setText("Recibo N°:");
        panelCamposFactura1.add(reciboNumero1, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 20, -1, -1));

        astReciboNumero1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astReciboNumero1.setToolTipText("Campo obligatorio");
        panelCamposFactura1.add(astReciboNumero1, new org.netbeans.lib.awtextra.AbsoluteConstraints(77, 13, -1, -1));

        fecha1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        fecha1.setText("Fecha:");
        panelCamposFactura1.add(fecha1, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 46, -1, -1));

        estudiante1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        estudiante1.setText("Estudiante:");
        panelCamposFactura1.add(estudiante1, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 69, -1, 22));

        astEstudiante1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astEstudiante1.setToolTipText("Campo obligatorio");
        panelCamposFactura1.add(astEstudiante1, new org.netbeans.lib.awtextra.AbsoluteConstraints(82, 69, -1, -1));

        recibido1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        recibido1.setText("Recibimos de:");
        panelCamposFactura1.add(recibido1, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 98, -1, 22));

        astRecibido1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astRecibido1.setToolTipText("Campo obligatorio");
        panelCamposFactura1.add(astRecibido1, new org.netbeans.lib.awtextra.AbsoluteConstraints(96, 98, -1, -1));

        formaPago1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        formaPago1.setText("Número de");
        panelCamposFactura1.add(formaPago1, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 121, 120, 22));

        astFormaPago1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astFormaPago1.setToolTipText("Campo obligatorio");
        panelCamposFactura1.add(astFormaPago1, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 120, -1, -1));

        campoRecibido1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        campoRecibido1.setEnabled(false);
        campoRecibido1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                campoRecibido1KeyTyped(evt);
            }
        });
        panelCamposFactura1.add(campoRecibido1, new org.netbeans.lib.awtextra.AbsoluteConstraints(163, 92, 330, 22));

        campoEstudiante1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        panelCamposFactura1.add(campoEstudiante1, new org.netbeans.lib.awtextra.AbsoluteConstraints(163, 69, 330, 22));

        campoFecha1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        campoFecha1.setText("Fecha obtenida desde sistema");
        panelCamposFactura1.add(campoFecha1, new org.netbeans.lib.awtextra.AbsoluteConstraints(163, 46, 330, 22));

        campoNumeroFormaPago1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        campoNumeroFormaPago1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                campoNumeroFormaPago1KeyTyped(evt);
            }
        });
        panelCamposFactura1.add(campoNumeroFormaPago1, new org.netbeans.lib.awtextra.AbsoluteConstraints(163, 121, 330, 22));

        campoMesFactura1.setEnabled(false);
        campoMesFactura1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        campoMesFactura1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                campoMesFactura1PropertyChange(evt);
            }
        });

        campoAnioFactura1.setEnabled(false);
        campoAnioFactura1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                campoAnioFactura1PropertyChange(evt);
            }
        });

        btnSeleccionarEst1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        btnSeleccionarEst1.setText("Seleccionar Estudiante");
        btnSeleccionarEst1.setEnabled(false);
        btnSeleccionarEst1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnSeleccionarEst1MouseClicked(evt);
            }
        });

        cajaFormaPago1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        cajaFormaPago1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Forma de Pago:", "Efectivo", "Cheque", "Depósito", "Tarjeta de Crédito" }));
        cajaFormaPago1.setEnabled(false);
        cajaFormaPago1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cajaFormaPago1ItemStateChanged(evt);
            }
        });
        cajaFormaPago1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cajaFormaPago1ActionPerformed(evt);
            }
        });

        scrollServicios1.setBackground(new java.awt.Color(0, 153, 254));
        scrollServicios1.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true), "Servicios a cobrar:", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Calibri", 1, 18), new java.awt.Color(255, 255, 255))); // NOI18N

        tablaServicios1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        tablaServicios1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Concepto de", "Profesor", "Modalidad", "Monto"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tablaServicios1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        tablaServicios1.setGridColor(new java.awt.Color(0, 102, 204));
        tablaServicios1.getTableHeader().setResizingAllowed(false);
        tablaServicios1.getTableHeader().setReorderingAllowed(false);
        scrollServicios1.setViewportView(tablaServicios1);

        btnCancelarFacturar1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        btnCancelarFacturar1.setText("Cancelar");
        btnCancelarFacturar1.setEnabled(false);
        btnCancelarFacturar1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnCancelarFacturar1MouseClicked(evt);
            }
        });

        btnAgregarFacturar1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        btnAgregarFacturar1.setText("Agregar Factura");
        btnAgregarFacturar1.setEnabled(false);
        btnAgregarFacturar1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnAgregarFacturar1MouseClicked(evt);
            }
        });
        btnAgregarFacturar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarFacturar1ActionPerformed(evt);
            }
        });

        panelCobros3.setBackground(new java.awt.Color(255, 255, 255));
        panelCobros3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 204, 255), 2));
        panelCobros3.setOpaque(false);

        pagoInicial1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        pagoInicial1.setText("Pago inicial:");

        saldo1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        saldo1.setText("Saldo:");

        campoPagoInicial1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        campoPagoInicial1.setEnabled(false);
        campoPagoInicial1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                campoPagoInicial1KeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                campoPagoInicial1KeyTyped(evt);
            }
        });

        campoSaldo1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N

        astPagoInicial1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astPagoInicial1.setToolTipText("Campo obligatorio");

        javax.swing.GroupLayout panelCobros3Layout = new javax.swing.GroupLayout(panelCobros3);
        panelCobros3.setLayout(panelCobros3Layout);
        panelCobros3Layout.setHorizontalGroup(
            panelCobros3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCobros3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(panelCobros3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(saldo1)
                    .addGroup(panelCobros3Layout.createSequentialGroup()
                        .addComponent(pagoInicial1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(astPagoInicial1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(4, 4, 4)
                .addGroup(panelCobros3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(campoPagoInicial1, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(campoSaldo1, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(185, 185, 185))
        );
        panelCobros3Layout.setVerticalGroup(
            panelCobros3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCobros3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelCobros3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelCobros3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(pagoInicial1)
                        .addComponent(campoPagoInicial1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(astPagoInicial1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelCobros3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelCobros3Layout.createSequentialGroup()
                        .addGap(0, 5, Short.MAX_VALUE)
                        .addComponent(saldo1))
                    .addComponent(campoSaldo1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        panelCobros1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 204, 255), 2));
        panelCobros1.setOpaque(false);

        sumaTotal1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        sumaTotal1.setText("Suma total:");

        rebajoTotalDescuentos1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        rebajoTotalDescuentos1.setText("Descuento total aplicado:");

        totalReal1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
        totalReal1.setText("Total real a pagar:");

        campoSumaTotal1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N

        campoRebajoTotalDescuentos1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N

        campoTotalReal1.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N

        javax.swing.GroupLayout panelCobros1Layout = new javax.swing.GroupLayout(panelCobros1);
        panelCobros1.setLayout(panelCobros1Layout);
        panelCobros1Layout.setHorizontalGroup(
            panelCobros1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCobros1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(panelCobros1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(panelCobros1Layout.createSequentialGroup()
                        .addComponent(sumaTotal1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(campoSumaTotal1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelCobros1Layout.createSequentialGroup()
                        .addComponent(totalReal1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(campoTotalReal1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelCobros1Layout.createSequentialGroup()
                        .addComponent(rebajoTotalDescuentos1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(campoRebajoTotalDescuentos1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(190, 190, 190))
        );
        panelCobros1Layout.setVerticalGroup(
            panelCobros1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCobros1Layout.createSequentialGroup()
                .addGroup(panelCobros1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sumaTotal1)
                    .addComponent(campoSumaTotal1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addGroup(panelCobros1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rebajoTotalDescuentos1)
                    .addComponent(campoRebajoTotalDescuentos1))
                .addGap(18, 18, 18)
                .addGroup(panelCobros1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(totalReal1)
                    .addComponent(campoTotalReal1)))
        );

        btnAyuda1.setFont(new java.awt.Font("Calibri", 0, 16)); // NOI18N
        btnAyuda1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/ayuda.png"))); // NOI18N
        btnAyuda1.setText("Ayuda");
        btnAyuda1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnAyuda1MouseClicked(evt);
            }
        });
        btnAyuda1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAyuda1ActionPerformed(evt);
            }
        });

        btnNuevaFactura1.setFont(new java.awt.Font("Calibri", 0, 16)); // NOI18N
        btnNuevaFactura1.setText("Nueva Factura");

        campoHora1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                campoHora1btnNuevaFacturaMouseClicked(evt);
            }
        });

        astEstudiante3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astEstudiante3.setToolTipText("Campo obligatorio");

        astFormaPago3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astFormaPago3.setToolTipText("Campo obligatorio");

        astPeriodo1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Img/asterisco.png"))); // NOI18N
        astPeriodo1.setToolTipText("Campo obligatorio");

        javax.swing.GroupLayout panelManejoFactura1Layout = new javax.swing.GroupLayout(panelManejoFactura1);
        panelManejoFactura1.setLayout(panelManejoFactura1Layout);
        panelManejoFactura1Layout.setHorizontalGroup(
            panelManejoFactura1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelManejoFactura1Layout.createSequentialGroup()
                .addGap(67, 67, 67)
                .addGroup(panelManejoFactura1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelManejoFactura1Layout.createSequentialGroup()
                        .addComponent(scrollServicios1, javax.swing.GroupLayout.PREFERRED_SIZE, 973, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(68, Short.MAX_VALUE))
                    .addGroup(panelManejoFactura1Layout.createSequentialGroup()
                        .addComponent(panelCamposFactura1, javax.swing.GroupLayout.PREFERRED_SIZE, 512, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(49, 49, 49)
                        .addGroup(panelManejoFactura1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panelManejoFactura1Layout.createSequentialGroup()
                                .addGap(2, 2, 2)
                                .addGroup(panelManejoFactura1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(campoMesFactura1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(panelManejoFactura1Layout.createSequentialGroup()
                                        .addGap(110, 110, 110)
                                        .addComponent(campoAnioFactura1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(astPeriodo1))
                            .addGroup(panelManejoFactura1Layout.createSequentialGroup()
                                .addComponent(btnSeleccionarEst1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(astEstudiante3))
                            .addGroup(panelManejoFactura1Layout.createSequentialGroup()
                                .addComponent(cajaFormaPago1, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(astFormaPago3)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86, Short.MAX_VALUE)
                        .addGroup(panelManejoFactura1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(btnNuevaFactura1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btnAyuda1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(97, 97, 97))))
            .addGroup(panelManejoFactura1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelManejoFactura1Layout.createSequentialGroup()
                    .addContainerGap(77, Short.MAX_VALUE)
                    .addComponent(panelCobros1, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(63, 63, 63)
                    .addComponent(panelCobros3, javax.swing.GroupLayout.PREFERRED_SIZE, 252, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(74, 74, 74)
                    .addComponent(btnAgregarFacturar1)
                    .addGap(26, 26, 26)
                    .addComponent(btnCancelarFacturar1, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 83, Short.MAX_VALUE)))
        );
        panelManejoFactura1Layout.setVerticalGroup(
            panelManejoFactura1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelManejoFactura1Layout.createSequentialGroup()
                .addGroup(panelManejoFactura1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelManejoFactura1Layout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addGroup(panelManejoFactura1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(panelManejoFactura1Layout.createSequentialGroup()
                                .addGroup(panelManejoFactura1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(campoMesFactura1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(campoAnioFactura1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(astPeriodo1))
                                .addGap(17, 17, 17)
                                .addGroup(panelManejoFactura1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(btnSeleccionarEst1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(astEstudiante3))
                                .addGap(13, 13, 13)
                                .addGroup(panelManejoFactura1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cajaFormaPago1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(astFormaPago3)))
                            .addGroup(panelManejoFactura1Layout.createSequentialGroup()
                                .addComponent(btnAyuda1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnNuevaFactura1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addGroup(panelManejoFactura1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(panelCamposFactura1, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(scrollServicios1, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(129, Short.MAX_VALUE))
            .addGroup(panelManejoFactura1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelManejoFactura1Layout.createSequentialGroup()
                    .addContainerGap(386, Short.MAX_VALUE)
                    .addGroup(panelManejoFactura1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(panelCobros1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(panelCobros3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(panelManejoFactura1Layout.createSequentialGroup()
                            .addGap(21, 21, 21)
                            .addGroup(panelManejoFactura1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(btnAgregarFacturar1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(btnCancelarFacturar1, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGap(0, 17, Short.MAX_VALUE)))
        );

        panelAnularFactura.add(panelManejoFactura1, new org.netbeans.lib.awtextra.AbsoluteConstraints(65, 18, 1120, 520));

        panelOpciones.addTab("Anular Factura", panelAnularFactura);

        javax.swing.GroupLayout panelImagenFacturacion2Layout = new javax.swing.GroupLayout(panelImagenFacturacion2);
        panelImagenFacturacion2.setLayout(panelImagenFacturacion2Layout);
        panelImagenFacturacion2Layout.setHorizontalGroup(
            panelImagenFacturacion2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImagenFacturacion2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(panelOpciones, javax.swing.GroupLayout.PREFERRED_SIZE, 1255, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(43, 43, 43))
        );
        panelImagenFacturacion2Layout.setVerticalGroup(
            panelImagenFacturacion2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelImagenFacturacion2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelOpciones, javax.swing.GroupLayout.PREFERRED_SIZE, 589, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelImagenFacturacion, javax.swing.GroupLayout.DEFAULT_SIZE, 1308, Short.MAX_VALUE)
            .addComponent(panelImagenFacturacion2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(panelImagenFacturacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(panelImagenFacturacion2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-1323)/2, (screenSize.height-726)/2, 1323, 726);
    }// </editor-fold>//GEN-END:initComponents

    private void jLabel6MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel6MouseEntered
        // TODO add your handling code here:
        Font font = new Font("Tahoma", Font.PLAIN, 11);
        Map attributes = font.getAttributes();
        attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
        jLabel6.setFont(font.deriveFont(attributes));
        jLabel6.setForeground(new Color(0,0,204));
    }//GEN-LAST:event_jLabel6MouseEntered

    private void jLabel6MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel6MouseExited
        // TODO add your handling code here:
        jLabel6.setFont(new Font("Tahoma", Font.PLAIN, 11));
        jLabel6.setForeground(new Color(0,0,0));
    }//GEN-LAST:event_jLabel6MouseExited

    private void jLabel6MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel6MousePressed
        // TODO add your handling code here:
        VentanaPrincipal ob= new VentanaPrincipal();
        ob.setVisible(true);
        dispose();
    }//GEN-LAST:event_jLabel6MousePressed

    private void panelOpcionesStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_panelOpcionesStateChanged
        // TODO add your handling code here:
        Component comp = panelOpciones.getSelectedComponent();
        if (comp.equals(panelGenerarFactura)){
            cancelarFacturar();
        }
    }//GEN-LAST:event_panelOpcionesStateChanged

    private void cajaFormaPagoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cajaFormaPagoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cajaFormaPagoActionPerformed

    private void btnAgregarFacturarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarFacturarActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnAgregarFacturarActionPerformed

    private void btnAyudaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnAyudaMouseClicked
        // TODO add your handling code here:
        //mensajeAyudaPanelUsuarios();
    }//GEN-LAST:event_btnAyudaMouseClicked

    private void btnNuevaFacturaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnNuevaFacturaMouseClicked
        // TODO add your handling code here:
        nuevaFactura();
    }//GEN-LAST:event_btnNuevaFacturaMouseClicked

    private void btnAyudaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAyudaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnAyudaActionPerformed

    private void campoRecibidoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoRecibidoKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if(!(Character.isLetter(c)||Character.isSpaceChar(c) ||(c == KeyEvent.VK_BACK_SPACE)||(c== KeyEvent.VK_DELETE))){
            getToolkit().beep();
            evt.consume();
        }
    }//GEN-LAST:event_campoRecibidoKeyTyped

    private void campoReciboNumeroKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoReciboNumeroKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if(!(Character.isDigit(c) ||(c == KeyEvent.VK_BACK_SPACE)||(c== KeyEvent.VK_DELETE))){
            getToolkit().beep();
            evt.consume();
        }
    }//GEN-LAST:event_campoReciboNumeroKeyTyped

    private void campoNumeroFormaPagoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoNumeroFormaPagoKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if(!(Character.isDigit(c) ||(c == KeyEvent.VK_BACK_SPACE)||(c== KeyEvent.VK_DELETE))){
            getToolkit().beep();
            evt.consume();
        }
    }//GEN-LAST:event_campoNumeroFormaPagoKeyTyped

    private void cajaFormaPagoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cajaFormaPagoItemStateChanged
        // TODO add your handling code here:
        if (evt.getStateChange() == ItemEvent.SELECTED) {
            actualizarControlesIngresarFactura();
        }
        habilitarCampoNumeroFormaPago();
    }//GEN-LAST:event_cajaFormaPagoItemStateChanged

    private void btnAgregarFacturarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnAgregarFacturarMouseClicked
        // TODO add your handling code here:
        puedeIngresarFactura();
    }//GEN-LAST:event_btnAgregarFacturarMouseClicked

    private void btnSeleccionarEstMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSeleccionarEstMouseClicked
        // TODO add your handling code here:
        popUpSeleccionarEstudianteFacturar();
    }//GEN-LAST:event_btnSeleccionarEstMouseClicked

    private void btnCancelarFacturarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCancelarFacturarMouseClicked
        // TODO add your handling code here:
        cancelarFacturar();
    }//GEN-LAST:event_btnCancelarFacturarMouseClicked

    private void campoMesFacturaPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_campoMesFacturaPropertyChange
        // TODO add your handling code here:
        setUnaVezListenerCalendar();
        cargarTipoLineaDetalleEstudiantePendiente();
    }//GEN-LAST:event_campoMesFacturaPropertyChange

    private void campoAnioFacturaPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_campoAnioFacturaPropertyChange
        // TODO add your handling code here:
        setUnaVezListenerCalendar();
        cargarTipoLineaDetalleEstudiantePendiente();
    }//GEN-LAST:event_campoAnioFacturaPropertyChange

    private void campoPagoInicialKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoPagoInicialKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if(!(Character.isDigit(c) ||(c == KeyEvent.VK_BACK_SPACE)||(c== KeyEvent.VK_DELETE))){
            getToolkit().beep();
            evt.consume();
        }
    }//GEN-LAST:event_campoPagoInicialKeyTyped

    private void campoPagoInicialKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoPagoInicialKeyReleased
        // TODO add your handling code here:
        calculoSaldo();
    }//GEN-LAST:event_campoPagoInicialKeyReleased

    private void campoReciboNumero1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoReciboNumero1KeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_campoReciboNumero1KeyTyped

    private void campoRecibido1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoRecibido1KeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_campoRecibido1KeyTyped

    private void campoNumeroFormaPago1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoNumeroFormaPago1KeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_campoNumeroFormaPago1KeyTyped

    private void campoMesFactura1PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_campoMesFactura1PropertyChange
        // TODO add your handling code here:
    }//GEN-LAST:event_campoMesFactura1PropertyChange

    private void campoAnioFactura1PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_campoAnioFactura1PropertyChange
        // TODO add your handling code here:
    }//GEN-LAST:event_campoAnioFactura1PropertyChange

    private void btnSeleccionarEst1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSeleccionarEst1MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_btnSeleccionarEst1MouseClicked

    private void cajaFormaPago1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cajaFormaPago1ItemStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_cajaFormaPago1ItemStateChanged

    private void cajaFormaPago1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cajaFormaPago1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cajaFormaPago1ActionPerformed

    private void btnCancelarFacturar1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCancelarFacturar1MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_btnCancelarFacturar1MouseClicked

    private void btnAgregarFacturar1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnAgregarFacturar1MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_btnAgregarFacturar1MouseClicked

    private void btnAgregarFacturar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarFacturar1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnAgregarFacturar1ActionPerformed

    private void campoPagoInicial1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoPagoInicial1KeyReleased
        // TODO add your handling code here:
    }//GEN-LAST:event_campoPagoInicial1KeyReleased

    private void campoPagoInicial1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoPagoInicial1KeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_campoPagoInicial1KeyTyped

    private void btnAyuda1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnAyuda1MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_btnAyuda1MouseClicked

    private void btnAyuda1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAyuda1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnAyuda1ActionPerformed

    private void campoHora1btnNuevaFacturaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_campoHora1btnNuevaFacturaMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_campoHora1btnNuevaFacturaMouseClicked

    private void initComponents2(){
        scrollServicios.getViewport().setBackground(Color.WHITE);
        JSpinner spinner = (JSpinner)campoAnioFactura.getSpinner();
        ((javax.swing.JTextField)spinner.getEditor()).setEditable(false);//983
        astReciboNumero.setVisible(false);
        Calendar a = Calendar.getInstance();
        campoFecha.setText(""+a.get(Calendar.DAY_OF_MONTH)+" de "+switchMes(a.get(Calendar.MONTH))+" de "+a.get(Calendar.YEAR));
        astEstudiante.setVisible(false);
        astEstudiante2.setVisible(false);
        astRecibido.setVisible(false);
        astPeriodo.setVisible(false);
        formaPago.setVisible(false);
        astFormaPago.setVisible(false);
        astFormaPago2.setVisible(false);
        campoNumeroFormaPago.setVisible(false);
        astPagoInicial.setVisible(false);
        tablaServicios.getColumnModel().getColumn(0).setMaxWidth(381);
        tablaServicios.getColumnModel().getColumn(0).setMinWidth(381);
        tablaServicios.getColumnModel().getColumn(1).setMaxWidth(382);
        tablaServicios.getColumnModel().getColumn(1).setMinWidth(382);
        tablaServicios.getColumnModel().getColumn(2).setMaxWidth(110);
        tablaServicios.getColumnModel().getColumn(2).setMinWidth(110);
        tablaServicios.getColumnModel().getColumn(3).setMaxWidth(110);
        tablaServicios.getColumnModel().getColumn(3).setMinWidth(110);
        
        DocumentListener controlCambios = new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent de) {
                actualizarControlesIngresarFactura();
            }

            @Override
            public void removeUpdate(DocumentEvent de) {
                actualizarControlesIngresarFactura();
            }

            @Override
            public void changedUpdate(DocumentEvent de) {
                actualizarControlesIngresarFactura();
            }
 
        };
        
        
        campoReciboNumero.getDocument().addDocumentListener(controlCambios);
        campoRecibido.getDocument().addDocumentListener(controlCambios);
        campoNumeroFormaPago.getDocument().addDocumentListener(controlCambios);
        campoPagoInicial.getDocument().addDocumentListener(controlCambios);
    }
    
    private String switchMes(int paramMes){
        switch (paramMes) { 
            case 0:  return "Enero";
            case 1:  return "Febrero";
            case 2:  return "Marzo";
            case 3:  return "Abril";
            case 4:  return "Mayo";
            case 5:  return "Junio";
            case 6:  return "Julio";
            case 7:  return "Agosto";
            case 8:  return "Setiembre";
            case 9:  return "Octubre";
            case 10:  return "Noviembre";
            case 11:  return "Diciembre";
        }
        return "";
    }
    
    private void nuevaFactura(){
        if(btnNuevaFactura.isEnabled()){
            btnNuevaFactura.setEnabled(false);
            astReciboNumero.setVisible(true);
            campoReciboNumero.setBackground(Color.white);
            campoReciboNumero.setEnabled(true);
            astRecibido.setVisible(true);
            astEstudiante.setVisible(true);
            astEstudiante2.setVisible(true);
            campoRecibido.setBackground(Color.white);
            campoRecibido.setEnabled(true);
            astPeriodo.setVisible(true);
            campoAnioFactura.setEnabled(true);
            campoMesFactura.setEnabled(true);
            btnSeleccionarEst.setEnabled(true);
            astFormaPago2.setVisible(true);
            cajaFormaPago.setEnabled(true);
            btnCancelarFacturar.setEnabled(true);
            campoSumaTotal.setText("");
            campoRebajoTotalDescuentos.setText("");
            campoTotalReal.setText("");
            campoPagoInicial.setText("");
            campoPagoInicial.setBackground(new Color(240,240,240));
            campoReciboNumero.requestFocus();
        }
    }
    
    private boolean minLargoRecibido(){
        if(campoRecibido.getText().length()>3){
            return true;
        }
        else{
            return false;
        }
    }
    
    private boolean maxLargoRecibido(){
        if(campoRecibido.getText().length()<101){
            return true;
        }
        else{
            return false;
        }
    }
    
    private boolean maxLargoId(){
        if(campoReciboNumero.getText().length()<10){
            return true;
        }
        else{
            return false;
        }
    }
    
    private boolean maxLargoFormaPago(){
        if(campoNumeroFormaPago.getText().length()<10){
            return true;
        }
        else{
            return false;
        }
    }
    
    private boolean maxLargoPagoInicial(){
        if(campoPagoInicial.getText().length()<10){
            return true;
        }
        else{
            return false;
        }
    }
    
    private boolean pagoInicialDeCero(){
        if(campoPagoInicial.isEnabled()){
            if(Integer.parseInt(campoPagoInicial.getText())!=0){
                return true;
            }
            else{
                return false;
            }
        }
        else{
            return true;
        }
    }
    
    private boolean pagoInicialNoMayor(){
        if(campoPagoInicial.isEnabled()){
            if(Integer.parseInt(campoPagoInicial.getText())<=parsearMonto(campoTotalReal.getText())){
                return true;
            }
            else{
                return false;
            }
        }
        else{
            return true;
        }
    }
    
    private boolean filtrosIngresarFactura(){
        int filtro1,filtro2,filtro3,filtro4,filtro5,filtro6;
        filtro1=filtro2=filtro3=filtro4=filtro5=filtro6=0;
        
        if(!maxLargoId()){
            filtro1=1;
        }
        if(!minLargoRecibido()||!maxLargoRecibido()){
            filtro2=1;
        }
        if(!maxLargoFormaPago()){
            filtro3=1;
        }
        if(!maxLargoPagoInicial()){
            filtro4=1;
        }
        if(!pagoInicialDeCero()){
            filtro5=1;
        }
        if(!pagoInicialDeCero()){
            filtro5=1;
        }
        if(!pagoInicialNoMayor()){
            filtro6=1;
        }
                
        return filtroAvisosIngresarFactura(filtro1,filtro2,filtro3,filtro4,filtro5,filtro6,cajaFormaPago.getSelectedItem()+"");
        
    }
    
    private boolean filtroAvisosIngresarFactura(int filtro1, int filtro2, int filtro3, int filtro4, int filtro5, int filtro6, String formaPago){
        String aviso1,aviso2,aviso3,aviso4,aviso5,aviso6;
        aviso1=aviso2=aviso3=aviso4=aviso5=aviso6="";
        
        if(filtro1==1){
            aviso1="\nEl número de factura no puede ser una cifra más allá de 9 dígitos";
        }
        
        if(filtro2==1){
            aviso2="\nEl nombre completo del responsable no puede tener más de 100 y no menos de 4 caracteres";
        }
        if(filtro3==1){
            if(formaPago.equals("Cheque")){
                aviso3="\nEl número de cheque no puede ser una cifra más allá de 9 dígitos";
            }
            else{
                if(formaPago.equals("Depósito")){
                    aviso3="\nEl número de depósito directo no puede ser una cifra más allá de 9 dígitos";
                }
                else{
                    if(formaPago.equals("Tarjeta de Crédito")){
                        aviso3="\nEl número de voucher no puede ser una cifra más allá de 9 dígitos";
                    }
                }
            }
        }
        if(filtro4==1){
            aviso4="\nEl monto de pago inicial no puede ser una cifra más allá de 9 dígitos";
        }
        if(filtro5==1){
            aviso5="\nNo se admiten pagos iniciales de 0 colones en la factura";
        }
        if(filtro6==1){
            aviso6="\nNo se admiten pagos iniciales mayores al monto total real a pagar";
        }
                
        subrayadoErrorIngresarFactura(filtro1,filtro2,filtro3,filtro4,filtro5,filtro6,formaPago);
        
        if(aviso1.equals("")&&aviso2.equals("")&&aviso3.equals("")&&aviso4.equals("")&&aviso5.equals("")&&aviso6.equals("")){
            return true;
        }
        else{
            JOptionPane.showMessageDialog(null, aviso1+aviso2+aviso3+aviso4+aviso5+aviso6, "Error", JOptionPane.ERROR_MESSAGE);
            return false;
        }
    }
    
    
    private void subrayadoErrorIngresarFactura(int filtro1, int filtro2, int filtro3, int filtro4, int filtro5, int filtro6, String formaPago){
        
        if(filtro1==1){
            campoReciboNumero.setBackground(new Color(255,51,51));
            campoReciboNumero.setToolTipText("Revisar número de factura");
        }
        if(filtro1==0){
            campoReciboNumero.setBackground(Color.white);
            campoReciboNumero.setToolTipText(null);
        }
        if(filtro2==1){
            campoRecibido.setBackground(new Color(255,51,51));
            campoRecibido.setToolTipText("Revisar nombre del responsable de pagar");
        }
        if(filtro2==0){
            campoRecibido.setBackground(Color.white);
            campoRecibido.setToolTipText(null);
        }
        if(filtro3==1){
            if(formaPago.equals("Cheque")){
                campoNumeroFormaPago.setBackground(new Color(255,51,51));
                campoNumeroFormaPago.setToolTipText("Revisar el número de cheque");
            }
            else{
                if(formaPago.equals("Depósito")){
                    campoNumeroFormaPago.setBackground(new Color(255,51,51));
                    campoNumeroFormaPago.setToolTipText("Revisar el número de depósito directo");
                }
                else{
                    if(formaPago.equals("Tarjeta de Crédito")){
                        campoNumeroFormaPago.setBackground(new Color(255,51,51));
                        campoNumeroFormaPago.setToolTipText("Revisar el número de voucher");
                    }
                }
            }
        }
        if(filtro3==0){
            campoNumeroFormaPago.setBackground(Color.white);
            campoNumeroFormaPago.setToolTipText(null);
        }
        if(filtro4==1||filtro5==1||filtro6==1){
            campoPagoInicial.setBackground(new Color(255,51,51));
            campoPagoInicial.setToolTipText("Revisar el monto de pago inicial");
        }
        if(filtro4==0&&filtro5==0&&filtro6==0){
            campoPagoInicial.setBackground(Color.white);
            campoPagoInicial.setToolTipText(null);
        }
        
    }
    
    private void actualizarControlesIngresarFactura(){
        if(campoReciboNumero.isEnabled()){
            puedeIngresarFactura2();
        }
    }
    
    private void puedeIngresarFactura2(){
        if(!campoReciboNumero.getText().equals("") && !campoRecibido.getText().equals("") && !campoEstudiante.getText().equals("") && (cajaFormaPago.getSelectedItem().equals("Efectivo") || (!campoNumeroFormaPago.getText().equals("") && !cajaFormaPago.getSelectedItem().equals("Forma de Pago:"))) && ((campoPagoInicial.isEnabled() && !campoPagoInicial.getText().equals("")) || !campoPagoInicial.isEnabled())){
            btnAgregarFacturar.setEnabled(true);
        }
        else{
            btnAgregarFacturar.setEnabled(false);
        }
        
    }
    
    private void puedeIngresarFactura(){
        if(btnAgregarFacturar.isEnabled()){
            if(filtrosIngresarFactura()){
                agregarFactura();
            }
        }
    }
    
    private void habilitarCampoNumeroFormaPago(){
        if(cajaFormaPago.getSelectedItem().equals("Efectivo") || cajaFormaPago.getSelectedItem().equals("Forma de Pago:")){
            astFormaPago.setVisible(false);
            formaPago.setVisible(false);
            formaPago.setText("");
            campoNumeroFormaPago.setText("");
            campoNumeroFormaPago.setVisible(false);
        }
        else{
            if(cajaFormaPago.getSelectedItem().equals("Cheque")){
                astFormaPago.setVisible(true);
                formaPago.setText("Número de cheque:");
                formaPago.setVisible(true);
                campoNumeroFormaPago.setVisible(true);
            }
            else{
                if(cajaFormaPago.getSelectedItem().equals("Depósito")){
                    astFormaPago.setVisible(true);
                    formaPago.setText("Número de depósito:");
                    formaPago.setVisible(true);
                    campoNumeroFormaPago.setVisible(true);
                }
                else{
                    if(cajaFormaPago.getSelectedItem().equals("Tarjeta de Crédito")){
                        astFormaPago.setVisible(true);
                        formaPago.setText("Número de voucher:");
                        formaPago.setVisible(true);
                        campoNumeroFormaPago.setVisible(true);
                    }
                }
            }
        }
    }
    
    public int getAnioSeleccionado(){
        return campoAnioFactura.getYear();
    }
    
    public int getMesSeleccionado(){
        return campoMesFactura.getMonth();
    }
    
    public void setEstudianteEscogidoFacturacion(String est, String est2){
        estSelec1=est;
        estSelec2=est2;
        campoEstudiante.setText(est+"-"+est2);
    }
    
    private void popUpSeleccionarEstudianteFacturar(){
        if(btnSeleccionarEst.isEnabled()){
            JDialog dialog = new JDialog ();
            dialog.setModal (true);
            dialog.setAlwaysOnTop (true);
            dialog.setModalityType (Dialog.ModalityType.APPLICATION_MODAL);
            PanelSeleccionarEstudianteFacturacion panelEst = new PanelSeleccionarEstudianteFacturacion(this,dialog);
            panelEst.cargarEstudiantesPendientes();
            dialog.add(panelEst);
            dialog.setSize(685, 538);
            dialog.setResizable(false);
            dialog.setLocationRelativeTo(null);
            dialog.setVisible(true);
        }
    }
    
    private int parsearMonto(String precio){
        precio=precio.substring(0, precio.length() - 2);
        precio=precio.replace(".","");
        precio=precio.replace(",","");
        precio=precio.replace("¢","");
        precio=precio.replace("C","");
        return Integer.parseInt(precio);
    }
    
    public int efectuoAbonos(){
        
        Connection conexion=null;
        Statement sentencia=null;
        ResultSet resultado=null;
        
        try {
            Class.forName("org.postgresql.Driver");
        }catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        try{ 
            conexion = DriverManager.getConnection(cadenaConexion);
            sentencia = conexion.createStatement();
            String consultaSQL="select mes from factura where estudiante='"+estSelec1+"' and anio="+campoAnioFactura.getYear()+" and mes="+campoMesFactura.getMonth();
            resultado = sentencia.executeQuery(consultaSQL);
            while(resultado.next()){
                return 1;
            } 
            
            return 0;
                                
            } catch (SQLException e) {
                JOptionPane.showMessageDialog(this, "\n Imposible determinar si el estudiante ha realizado abonos de los servicios del mes del año especificado\n Error en la base de datos", "Error", JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
                conexion = null;
            }
            finally {
                if (resultado != null) {
                    try {
                        resultado.close();
                    } catch (Exception e) {
                    e.printStackTrace();
                    }
                }
                if (sentencia != null) {
                    try {
                        sentencia.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                if (conexion != null) {
                    try {
                        conexion.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        
        return 2;
    }
    
    private String profesorDelGrupo(int curso, int numero){
        Connection conexion=null;
        Statement sentencia=null;
        ResultSet resultado=null;
        
        try {
            Class.forName("org.postgresql.Driver");
        }catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        try{ 
            conexion = DriverManager.getConnection(cadenaConexion);
            sentencia = conexion.createStatement();
            String consultaSQL="select cedula,nombre,apellido1,apellido2 from (select profesor from grupo where curso="+curso+" and numero="+numero+" and anio="+campoAnioFactura.getYear()+" and mes="+campoMesFactura.getMonth()+")alias1, (select cedula,nombre,apellido1,apellido2 from profesor)alias2 where alias1.profesor=alias2.cedula";
            resultado = sentencia.executeQuery(consultaSQL);
            while(resultado.next()){
                String prof; 
                prof=resultado.getString("cedula").replaceAll("\\s+$","")+"-";
                prof=prof+resultado.getString("nombre").replaceAll("\\s+$","")+" "+resultado.getString("apellido1").replaceAll("\\s+$","");
                if(resultado.getString("apellido2")!=null){
                    prof=prof+" "+resultado.getString("apellido2").replaceAll("\\s+$","");
                } 
                return prof;
            } 
                                
            } catch (SQLException e) {
                JOptionPane.showMessageDialog(this, "\n Imposible mostrar el profesor de curso matriculado por el estudiante\n Error en la base de datos", "Error", JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
                conexion = null;
            }
            finally {
                if (resultado != null) {
                    try {
                        resultado.close();
                    } catch (Exception e) {
                    e.printStackTrace();
                    }
                }
                if (sentencia != null) {
                    try {
                        sentencia.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                if (conexion != null) {
                    try {
                        conexion.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        return "";
    }
    
    private void cargarLineaDetalleEstudiantePendiente(){
        if(!campoEstudiante.getText().equals("")){
            Connection conexion=null;
            Statement sentencia=null;
            ResultSet resultado=null;
            Object[][] detalles=null;
        
            try {
                Class.forName("org.postgresql.Driver");
            }catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
            try{ 
                conexion = DriverManager.getConnection(cadenaConexion);
                sentencia = conexion.createStatement();
                String matricula="select curso,numero from matricula where estudiante='"+estSelec1+"' and anio="+campoAnioFactura.getYear()+" and mes="+campoMesFactura.getMonth()+" and retiro='false'";//and estudiante not in (select estudiante from factura where anio="+campoAnioFactura.getYear()+" and mes="+campoMesFactura.getMonth()+" and saldo::numeric='0' and estudiante='"+estSelec1+"'";
                String grupo="select modalidad,numero,curso from grupo where anio="+campoAnioFactura.getYear()+" and mes="+campoMesFactura.getMonth();
                String cruce="select modalidad,alias1.curso,alias1.numero from ("+matricula+")alias1,("+grupo+")alias2 where alias1.curso=alias2.curso and alias1.numero=alias2.numero"; // and alias1.curso not in (select curso from linea_detalle where estudiante='"+estSelec1+"' and anio="+campoAnioFactura.getYear()+" and mes="+campoMesFactura.getMonth()+")";
                String consultaSQL="select modalidad,curso,nombre,numero from ("+cruce+")alias4,(select nombre,codigo from curso)alias5 where alias4.curso=alias5.codigo";
            
                resultado = sentencia.executeQuery(consultaSQL);
                int detallesSize=0;
                while(resultado.next()){
                    detallesSize++;
                } 
            
                if(detallesSize!=0){
                    detalles=new Object[detallesSize][4];
                    detallesSize=0;
                    Statement sentencia2 = conexion.createStatement();
                    montos = new ArrayList();
                    cursos = new ArrayList();
                    numeros = new ArrayList();
                    precios = new ArrayList();
                    ResultSet resultado2 = sentencia2.executeQuery(consultaSQL);
                
                    while (resultado2.next()) {
                        detalles[detallesSize][0]="Clases: "+resultado2.getInt("curso")+"-"+resultado2.getString("nombre").replaceAll("\\s+$","");
                        if(resultado2.getInt("modalidad")==1){
                            detalles[detallesSize][2]="Individual";
                            String indiv=cargarMontoServicio(2);
                            detalles[detallesSize][3]=indiv;
                            montos.add(parsearMonto(indiv));
                            precios.add(indiv);
                            numeros.add(resultado2.getInt("numero"));
                            cursos.add(resultado2.getInt("curso"));
                        }
                        else{
                            detalles[detallesSize][2]="Compartida";
                            String comp=cargarMontoServicio(3);
                            detalles[detallesSize][3]=comp;
                            montos.add(parsearMonto(comp));
                            precios.add(comp);
                            numeros.add(resultado2.getInt("numero"));
                            cursos.add(resultado2.getInt("curso"));
                        }
                        detalles[detallesSize][1]=profesorDelGrupo(resultado2.getInt("curso"),resultado2.getInt("numero"));
                        detallesSize++;
                    }
                
                }
                                
            } catch (SQLException e) {
                JOptionPane.showMessageDialog(this, "\n Imposible cargar los servicios a cobrar del estudiante pendiente\n Error en la base de datos", "Error", JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
                conexion = null;
            }
            finally {
                if (resultado != null) {
                    try {
                        resultado.close();
                    } catch (Exception e) {
                    e.printStackTrace();
                    }
                }
                if (sentencia != null) {
                    try {
                        sentencia.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                if (conexion != null) {
                    try {
                        conexion.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        
            tablaServicios.setModel(new javax.swing.table.DefaultTableModel(
                detalles,
                
                new String [] {
                    "Concepto de", "Profesor", "Modalidad", "Monto"
                }
            ) {
                boolean[] canEdit = new boolean [] {
                    false, false, false, false
                };

                public boolean isCellEditable(int rowIndex, int columnIndex) {
                    return canEdit [columnIndex];
                }
            });  
        
            tablaServicios.getColumnModel().getColumn(0).setMaxWidth(381);
            tablaServicios.getColumnModel().getColumn(0).setMinWidth(381);
            tablaServicios.getColumnModel().getColumn(1).setMaxWidth(382);
            tablaServicios.getColumnModel().getColumn(1).setMinWidth(382);
            tablaServicios.getColumnModel().getColumn(2).setMaxWidth(110);
            tablaServicios.getColumnModel().getColumn(2).setMinWidth(110);
            tablaServicios.getColumnModel().getColumn(3).setMaxWidth(110);
            tablaServicios.getColumnModel().getColumn(3).setMinWidth(110);
        
        
            if(seCobraMatricula()){
                String matri=cargarMontoServicio(1);
                ((DefaultTableModel)tablaServicios.getModel()).insertRow(0,new Object[]{"Matrícula", null, null, matri});
                matricula=parsearMonto(matri);
            }
            else{
                matricula=0;
            } 
            
            cargarDescuentosServicio();
        
            if(hayRecargo()){
                String recar=cargarMontoServicio(4);
                ((DefaultTableModel)tablaServicios.getModel()).insertRow(0,new Object[]{"Recargo", null, null, recar});
                recargo=parsearMonto(recar);
            }
            else{
                recargo=0;
            }
            
        }
    }
     
    private String cargarMontoServicio(int codigo){
        Connection conexion=null;
        Statement sentencia=null;
        ResultSet resultado=null;
               
        try {
            Class.forName("org.postgresql.Driver");
        }catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        try{
            conexion = DriverManager.getConnection(cadenaConexion);
            sentencia = conexion.createStatement();
        
            String consultaSQL = "select monto from monto where codigo="+codigo;
            resultado = sentencia.executeQuery(consultaSQL);
            
            while(resultado.next()){
                return resultado.getString("monto");
            }
                      
                    
        } catch (SQLException e) {
            JOptionPane.showMessageDialog(null, "\n Imposible cargar los montos de los servicios respectivos \n Error en la base de datos", "Error", JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
            conexion = null;
        }
        finally {
            if (resultado != null) {
                try {
                    resultado.close();
                } catch (Exception e) {
                e.printStackTrace();
                }
            }
            if (sentencia != null) {
                try {
                    sentencia.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (conexion != null) {
                try {
                    conexion.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return "";
    }
    
    private boolean seCobraMatricula(){
        Connection conexion=null;
        Statement sentencia=null;
        ResultSet resultado=null;
               
        try {
            Class.forName("org.postgresql.Driver");
        }catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        try{
            conexion = DriverManager.getConnection(cadenaConexion);
            sentencia = conexion.createStatement();
            String consultaSQL;
            if(campoMesFactura.getMonth()==0){
                consultaSQL = "select retiro from matricula where anio="+(campoAnioFactura.getYear()-1)+" and estudiante='"+estSelec1+"' and mes="+11+" and retiro='false'";
            }
            else{
                consultaSQL = "select retiro from matricula where anio="+campoAnioFactura.getYear()+" and estudiante='"+estSelec1+"' and mes="+(campoMesFactura.getMonth()-1)+" and retiro='false'";
            }
            resultado = sentencia.executeQuery(consultaSQL);
            
            while(resultado.next()){
                return false;
            }
            
            return true;
                      
                    
        } catch (SQLException e) {
            JOptionPane.showMessageDialog(null, "\n Imposible verificar si el estudiante ya pagó o no el concepto de matrícula\n Error en la base de datos", "Error", JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
            conexion = null;
        }
        finally {
            if (resultado != null) {
                try {
                    resultado.close();
                } catch (Exception e) {
                e.printStackTrace();
                }
            }
            if (sentencia != null) {
                try {
                    sentencia.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (conexion != null) {
                try {
                    conexion.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return false;
    }
    
    private String cargarDescuentosServicio(){
        Connection conexion=null;
        Statement sentencia=null;
        ResultSet resultado=null;
               
        try {
            Class.forName("org.postgresql.Driver");
        }catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        try{
            conexion = DriverManager.getConnection(cadenaConexion);
            sentencia = conexion.createStatement();
        
            String promocion_est = "select promocion from promocion_estudiantil where estudiante='"+estSelec1+"' and anio="+campoAnioFactura.getYear()+" and mes="+campoMesFactura.getMonth();
            String promocion= "select codigo,nombre,monto from promocion";
            String consultaSQL= "select codigo,nombre,monto from ("+promocion_est+")alias1,("+promocion+")alias2 where alias1.promocion=alias2.codigo";
            descuentos = new ArrayList();
            resultado = sentencia.executeQuery(consultaSQL);
            
            while(resultado.next()){
                if(!resultado.getString("monto").equals("¢0,00")){
                    ((DefaultTableModel)tablaServicios.getModel()).addRow(new Object[]{"Descuento: "+resultado.getInt("codigo")+"-"+resultado.getString("nombre").replaceAll("\\s+$",""), null, null, resultado.getString("monto")});
                    descuentos.add(parsearMonto(resultado.getString("monto")));
                }
                else{
                    ((DefaultTableModel)tablaServicios.getModel()).addRow(new Object[]{"Descuento: "+resultado.getInt("codigo")+"-"+resultado.getString("nombre").replaceAll("\\s+$",""), null, null, "Pago total"});
                    descuentos.add(parsearMonto(resultado.getString("monto")));
                }
            }                      
                    
        } catch (SQLException e) {
            JOptionPane.showMessageDialog(null, "\nImposible cargar los descuentos a aplicar en la facturación de servicios al estudiante\n Error en la base de datos", "Error", JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
            conexion = null;
        }
        finally {
            if (resultado != null) {
                try {
                    resultado.close();
                } catch (Exception e) {
                e.printStackTrace();
                }
            }
            if (sentencia != null) {
                try {
                    sentencia.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (conexion != null) {
                try {
                    conexion.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return "";
    }
    
    private void calculoMontoTotal(int valor){
        int monto=0;
        if(montos!=null){
            for(int i=0;i<montos.size();i++){
                monto=monto+(int)montos.get(i);
            }    
            if(monto!=0){
                if(matricula!=0){
                    monto=monto+matricula;
                }
                if(recargo!=0){
                    monto=monto+recargo;
                }
                NumberFormat fmt = NumberFormat.getCurrencyInstance();
                campoSumaTotal.setText(fmt.format(monto));
                calculoRebajoDescuentos(valor);
            }
        }
    }
    
    private void calculoRebajoDescuentos(int valor){
        campoRebajoTotalDescuentos.setText("Sin descuentos");
        if(descuentos.contains(0)){
            if(matricula==0){
                campoRebajoTotalDescuentos.setText("-"+campoSumaTotal.getText());
            }
            else{
                NumberFormat fmt = NumberFormat.getCurrencyInstance();
                if(recargo==0){
                    campoRebajoTotalDescuentos.setText("-"+fmt.format(parsearMonto(campoSumaTotal.getText())-matricula));
                }
                else{
                    campoRebajoTotalDescuentos.setText("-"+fmt.format(parsearMonto(campoSumaTotal.getText())-matricula-recargo));
                }
            }
        }
        else{
            int descuento=0;
            for(int i=0;i<descuentos.size();i++){
                descuento=descuento+(int)descuentos.get(i);
            }   
            if(descuento!=0){
                if(matricula==0){
                    NumberFormat fmt = NumberFormat.getCurrencyInstance();
                    campoRebajoTotalDescuentos.setText(fmt.format(descuento));
                    if(recargo==0){
                        if(parsearMonto(campoSumaTotal.getText())<descuento){//descuento es mayor al pago total
                            campoRebajoTotalDescuentos.setText("-"+fmt.format(parsearMonto(campoSumaTotal.getText())));
                        }
                        else{
                            campoRebajoTotalDescuentos.setText("-"+fmt.format(descuento));
                        }
                    }
                    else{
                        if(parsearMonto(campoSumaTotal.getText())-recargo<descuento){//descuento es mayor al pago total
                            campoRebajoTotalDescuentos.setText("-"+fmt.format(parsearMonto(campoSumaTotal.getText())-recargo));
                        }
                        else{
                            campoRebajoTotalDescuentos.setText("-"+fmt.format(descuento));
                        }
                    }
                }
                else{//paga matricula, ver si el descuento es mayor a el pago total sin la matricula
                    if(recargo==0){
                        NumberFormat fmt = NumberFormat.getCurrencyInstance();
                        if(parsearMonto(campoSumaTotal.getText())-matricula<descuento){//descuento es mayor al pago total
                            campoRebajoTotalDescuentos.setText("-"+fmt.format(parsearMonto(campoSumaTotal.getText())-matricula));//aunque tenga descuento mayor total al pago (quitando la matricula) aparecerá como descuento el monto total sin la matricula incluida
                        }
                        else{
                            campoRebajoTotalDescuentos.setText("-"+fmt.format(descuento));
                        }
                    }
                    else{
                        NumberFormat fmt = NumberFormat.getCurrencyInstance();
                        if(parsearMonto(campoSumaTotal.getText())-matricula-recargo<descuento){//descuento es mayor al pago total
                            campoRebajoTotalDescuentos.setText("-"+fmt.format(parsearMonto(campoSumaTotal.getText())-matricula-recargo));//aunque tenga descuento mayor total al pago (quitando la matricula) aparecerá como descuento el monto total sin la matricula incluida
                        }
                        else{
                            campoRebajoTotalDescuentos.setText("-"+fmt.format(descuento));
                        }
                    }
                }
            }
        }
        if(valor==0){
            totalRealPagarPrimerAbono();
        }
        else{
            totalRealPagarSigAbono();
        }
    }
    
    public boolean isInteger(String s) {
        try { 
            Integer.parseInt(s); 
        } catch(NumberFormatException e) { 
            return false; 
        }
    
        return true;
    }
    
    private void totalRealPagarPrimerAbono(){
        try{
            if(isInteger(parsearMonto(campoSumaTotal.getText())+"")){
                NumberFormat fmt = NumberFormat.getCurrencyInstance();
                try{
                    if(isInteger(parsearMonto(campoRebajoTotalDescuentos.getText())+"")){
                        campoTotalReal.setText(""+fmt.format(parsearMonto(campoSumaTotal.getText())+parsearMonto(campoRebajoTotalDescuentos.getText())));
                        habilitarAbono();
                    }
                }
                catch(NumberFormatException e){
                    campoTotalReal.setText(""+fmt.format(parsearMonto(campoSumaTotal.getText())));
                    habilitarAbono();
                }
            }
        }
        catch(NumberFormatException e){}
    }
    
    private void totalRealPagarSigAbono(){
        String ultimoSaldo;
        ultimoSaldo=ultimoSaldoEstudiante();
        if(!ultimoSaldo.equals("")){
            NumberFormat fmt = NumberFormat.getCurrencyInstance();
            campoTotalReal.setText(fmt.format(parsearMonto(ultimoSaldo)));
            habilitarAbono();
        }
    }
    
    private void habilitarAbono(){
        if(campoTotalReal.getText().equals("C0.00")){
            astPagoInicial.setVisible(false);
            campoPagoInicial.setBackground(Color.white);
            campoPagoInicial.setText(parsearMonto(campoSumaTotal.getText())+"");
            campoPagoInicial.setEnabled(false);
        }
        else{ 
            astPagoInicial.setVisible(true);
            campoPagoInicial.setBackground(Color.white);
            campoPagoInicial.setText("");
            campoPagoInicial.setEnabled(true);
            campoPagoInicial.requestFocus();
        }
    }
    
    private void agregarFactura(){
            int confirmado = JOptionPane.showOptionDialog(
                null,"¿Desea facturar los servicios recibidos del estudiante?\nConfirmar facturación", "Confirmación requerida",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE,
                null,    // null para icono por defecto.
                new Object[] { "Correcto", "Cancelar"},   // null para YES, NO y CANCEL
                null);
                
            if(confirmado==0){
                Connection conexion=null;
                Statement sentencia=null;
                ResultSet resultado=null;
        
                try {
                    Class.forName("org.postgresql.Driver");
                }catch (ClassNotFoundException e) {
                    e.printStackTrace();
                }
                try{
                    conexion = DriverManager.getConnection(cadenaConexion);
                    sentencia = conexion.createStatement();
                    String consultaSQL="";
                    try{
                        if(isInteger(parsearMonto(campoRebajoTotalDescuentos.getText())+"")){
                            consultaSQL = "insert into factura (id,fecha,responsable,estudiante,monto_total,descuento,monto_cancelado,saldo,servicio_matricula,anio,mes,monto_total_real,recargo) VALUES ("+Integer.parseInt(campoReciboNumero.getText())+",'"+new Timestamp(new java.util.Date().getTime())+"','"+campoRecibido.getText()+"','"+estSelec1+"',"+(parsearMonto(campoSumaTotal.getText())-matricula)+","+parsearMonto(campoRebajoTotalDescuentos.getText())+","+campoPagoInicial.getText()+","+parsearMonto(campoSaldo.getText())+","+matricula+","+campoAnioFactura.getYear()+","+campoMesFactura.getMonth()+","+parsearMonto(campoTotalReal.getText())+","+recargo+")";
                        }
                    }  
                    catch(NumberFormatException e){ 
                        consultaSQL = "insert into factura (id,fecha,responsable,estudiante,monto_total,descuento,monto_cancelado,saldo,servicio_matricula,anio,mes,monto_total_real,recargo) VALUES ("+Integer.parseInt(campoReciboNumero.getText())+",'"+new Timestamp(new java.util.Date().getTime())+"','"+campoRecibido.getText()+"','"+estSelec1+"',"+(parsearMonto(campoSumaTotal.getText())-matricula)+","+0+","+campoPagoInicial.getText()+","+parsearMonto(campoSaldo.getText())+","+matricula+","+campoAnioFactura.getYear()+","+campoMesFactura.getMonth()+","+parsearMonto(campoTotalReal.getText())+","+recargo+")";
                    }
                    resultado = sentencia.executeQuery(consultaSQL);

                } catch (SQLException e) {
                    if(e.getSQLState().equals("02000")){ //no_data , una inserción no devuelve nada
                        agregarTipoFactura();
                        agregarLineasDeDetalleFactura();
                        JOptionPane.showMessageDialog(null,"\n ¡Factura "+campoReciboNumero.getText().replaceAll("\\s+$","")+" añadida al sistema!","Éxito",JOptionPane.INFORMATION_MESSAGE);
                        cancelarFacturar();
                    }
                    else{       
                        if(e.getSQLState().equals("23505")){ //unique violation: llave duplicada
                            JOptionPane.showMessageDialog(null, "\nImposible añadir factura\nUna factura con dicho número de recibo ya ha sido registrada, por favor asegúrese de ingresar correctamete los datos", "Error", JOptionPane.ERROR_MESSAGE); 
                        }
                        else{
                            JOptionPane.showMessageDialog(null, "\nImposible añadir factura\nError en la base de datos", "Error", JOptionPane.ERROR_MESSAGE);
                            e.printStackTrace();
                            conexion = null;
                        }
                    }
                }
                finally {
                    if (resultado != null) {
                        try {
                            resultado.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    if (sentencia != null) {
                        try {
                            sentencia.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    if (conexion != null) {
                        try {
                            conexion.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    
    private void cancelarFacturar(){
        if(btnCancelarFacturar.isEnabled()){
            btnNuevaFactura.setEnabled(true);
            astReciboNumero.setVisible(false);
            campoReciboNumero.setBackground(new Color(240,240,240));
            campoReciboNumero.setToolTipText(null);
            campoReciboNumero.setText("");
            campoReciboNumero.setEnabled(false);
            astRecibido.setVisible(false);
            astEstudiante.setVisible(false);
            campoEstudiante.setText("");
            astEstudiante2.setVisible(false);
            campoRecibido.setBackground(new Color(240,240,240));
            campoRecibido.setToolTipText(null);
            campoRecibido.setText("");
            campoRecibido.setEnabled(false);
            astPeriodo.setVisible(false);
            campoAnioFactura.setEnabled(false);
            campoMesFactura.setEnabled(false);
            btnSeleccionarEst.setEnabled(false);
            astFormaPago2.setVisible(false);
            cajaFormaPago.setSelectedItem("Forma de Pago:");
            cajaFormaPago.setEnabled(false);
            btnCancelarFacturar.setEnabled(false);
            astFormaPago.setVisible(false);
            campoNumeroFormaPago.setText("");
            campoNumeroFormaPago.setToolTipText(null);
            campoNumeroFormaPago.setBackground(Color.white);
            campoNumeroFormaPago.setVisible(false);
            campoSumaTotal.setText("");
            campoRebajoTotalDescuentos.setText("");
            campoTotalReal.setText("");
            astPagoInicial.setVisible(false);
            campoPagoInicial.setBackground(new Color(240,240,240));
            campoPagoInicial.setToolTipText(null);
            campoPagoInicial.setText("");
            campoPagoInicial.setEnabled(false);
            campoSaldo.setText("");
            matricula=0;
            recargo=0;
            estSelec1="";
            estSelec2="";
            montos=new ArrayList();
            descuentos=new ArrayList();
            precios=new ArrayList();
            numeros=new ArrayList();
            cursos=new ArrayList();
            limpiarTablaServicios();
        }
    }
    
    private void calculoSaldo(){
        if(!campoPagoInicial.getText().equals("")){
            NumberFormat fmt = NumberFormat.getCurrencyInstance();
            if(parsearMonto(campoTotalReal.getText())>=Integer.parseInt(campoPagoInicial.getText())){
                campoSaldo.setText(fmt.format((parsearMonto(campoTotalReal.getText()))-Integer.parseInt(campoPagoInicial.getText())));
            }
            else{
                campoSaldo.setText(fmt.format(0));
            }
        }
        else{
            campoSaldo.setText("");
        }
    }
    
    private void limpiarTablaServicios(){
        tablaServicios.setModel(new javax.swing.table.DefaultTableModel(
                null,
                
            new String [] {
                "Concepto de", "Profesor", "Modalidad", "Monto"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });  
        
        tablaServicios.getColumnModel().getColumn(0).setMaxWidth(381);
        tablaServicios.getColumnModel().getColumn(0).setMinWidth(381);
        tablaServicios.getColumnModel().getColumn(1).setMaxWidth(382);
        tablaServicios.getColumnModel().getColumn(1).setMinWidth(382);
        tablaServicios.getColumnModel().getColumn(2).setMaxWidth(110);
        tablaServicios.getColumnModel().getColumn(2).setMinWidth(110);
        tablaServicios.getColumnModel().getColumn(3).setMaxWidth(110);
        tablaServicios.getColumnModel().getColumn(3).setMinWidth(110);
    }
    
    private boolean hayRecargo(){
        if(!descuentos.contains(0)){
            Calendar b = Calendar.getInstance();
            if(b.get(Calendar.YEAR)==campoAnioFactura.getYear()){
                if(b.get(Calendar.MONTH)==campoMesFactura.getMonth()){
                    if(b.get(Calendar.DAY_OF_MONTH)>7){
                        return true;
                    }
                    else{
                        return false;
                    }
                }
                else{
                    if(b.get(Calendar.MONTH)>campoMesFactura.getMonth()){
                        return true;
                    }
                    else{
                        return false;
                    }
                }
            }
            else{
                if(b.get(Calendar.YEAR)>campoAnioFactura.getYear()){
                    return true;
                }
                else{
                    return false;
                }
            }
        }
        else{
            return false;
        }
    }
    
    private void agregarLineasDeDetalleFactura(){
        for(int i=0;i<cursos.size();i++){
            Connection conexion=null;
            Statement sentencia=null;
            ResultSet resultado=null;
        
            try {
                Class.forName("org.postgresql.Driver");
            }catch (ClassNotFoundException e) {
                e.printStackTrace();
            } 
            try{
                conexion = DriverManager.getConnection(cadenaConexion);
                sentencia = conexion.createStatement();
                String consultaSQL="insert into linea_detalle(factura,curso,anio,mes,numero,estudiante,precio) VALUES ("+campoReciboNumero.getText()+","+cursos.get(i)+","+campoAnioFactura.getYear()+","+campoMesFactura.getMonth()+","+numeros.get(i)+",'"+estSelec1+"','"+precios.get(i)+"')";        
                resultado = sentencia.executeQuery(consultaSQL);

            } catch (SQLException e) {
                if(e.getSQLState().equals("02000")){ //no_data , una inserción no devuelve nada
                }
                else{       
                    if(e.getSQLState().equals("23505")){ //unique violation: llave duplicada
                        JOptionPane.showMessageDialog(null, "\nImposible añadir detalle de servicio de factura del estudiante\nUn detalle de servicio de factura del estudiante igual ya ha sido ingresado en la factura, por favor asegúrese de ingresar correctamete los datos", "Error", JOptionPane.ERROR_MESSAGE); 
                    }
                    else{
                        JOptionPane.showMessageDialog(null, "\nImposible añadir detalle de servicio de factura del estudiante\nError en la base de datos", "Error", JOptionPane.ERROR_MESSAGE);
                        e.printStackTrace();
                        conexion = null;
                    }
                }
            }
            finally {
                if (resultado != null) {
                    try {
                        resultado.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                if (sentencia != null) {
                    try {
                        sentencia.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                if (conexion != null) {
                    try {
                        conexion.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
    
    private void agregarTipoFactura(){
        if(cajaFormaPago.getSelectedItem().equals("Efectivo")){
            agregarFacturaEfectivo();
        }
        else{
            if(cajaFormaPago.getSelectedItem().equals("Cheque")){
                agregarFacturaCheque();
            }
            else{
                if(cajaFormaPago.getSelectedItem().equals("Depósito")){
                    agregarFacturaDeposito();
                }
                else{
                    if(cajaFormaPago.getSelectedItem().equals("Tarjeta de Crédito")){
                        agregarFacturaTarjeta();
                    }
                }
            }
        }
    }
    
    private void agregarFacturaEfectivo(){
        Connection conexion=null;
        Statement sentencia=null;
        ResultSet resultado=null;
        
        try {
            Class.forName("org.postgresql.Driver");
        }catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        try{
            conexion = DriverManager.getConnection(cadenaConexion);
            sentencia = conexion.createStatement();
            String consultaSQL="insert into factura_efectivo(factura) VALUES ("+campoReciboNumero.getText()+")";        
            resultado = sentencia.executeQuery(consultaSQL);

        } catch (SQLException e) {
            if(e.getSQLState().equals("02000")){ //no_data , una inserción no devuelve nada
            }
            else{       
                if(e.getSQLState().equals("23505")){ //unique violation: llave duplicada
                    JOptionPane.showMessageDialog(null, "\nImposible añadir factura de pago en efectivo\nUna factura de pago en efectivo con dicho número de recibo ya ha sido registrada, por favor asegúrese de ingresar correctamete los datos", "Error", JOptionPane.ERROR_MESSAGE); 
                }
                else{
                    JOptionPane.showMessageDialog(null, "\nImposible añadir factura de pago en efectivo\nError en la base de datos", "Error", JOptionPane.ERROR_MESSAGE);
                    e.printStackTrace();
                    conexion = null;
                }
            }
        }
        finally {
            if (resultado != null) {
                try {
                    resultado.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (sentencia != null) {
                try {
                    sentencia.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (conexion != null) {
                try {
                    conexion.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
    
    private void agregarFacturaCheque(){
        Connection conexion=null;
        Statement sentencia=null;
        ResultSet resultado=null;
        
        try {
            Class.forName("org.postgresql.Driver");
        }catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        try{
            conexion = DriverManager.getConnection(cadenaConexion);
            sentencia = conexion.createStatement();
            String consultaSQL="insert into factura_cheque(factura,numero_cheque) VALUES ("+campoReciboNumero.getText()+","+campoNumeroFormaPago.getText()+")";        
            resultado = sentencia.executeQuery(consultaSQL);

        } catch (SQLException e) {
            if(e.getSQLState().equals("02000")){ //no_data , una inserción no devuelve nada
            }
            else{       
                if(e.getSQLState().equals("23505")){ //unique violation: llave duplicada
                    JOptionPane.showMessageDialog(null, "\nImposible añadir factura de pago mediante cheque\nUna factura de pago mediante cheque con dicho número de recibo ya ha sido registrada, por favor asegúrese de ingresar correctamete los datos", "Error", JOptionPane.ERROR_MESSAGE); 
                }
                else{
                    JOptionPane.showMessageDialog(null, "\nImposible añadir factura de pago mediante cheque\nError en la base de datos", "Error", JOptionPane.ERROR_MESSAGE);
                    e.printStackTrace();
                    conexion = null;
                }
            }
        }
        finally {
            if (resultado != null) {
                try {
                    resultado.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (sentencia != null) {
                try {
                    sentencia.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (conexion != null) {
                try {
                    conexion.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
    
    private void agregarFacturaDeposito(){
        Connection conexion=null;
        Statement sentencia=null;
        ResultSet resultado=null;
        
        try {
            Class.forName("org.postgresql.Driver");
        }catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        try{
            conexion = DriverManager.getConnection(cadenaConexion);
            sentencia = conexion.createStatement();
            String consultaSQL="insert into factura_deposito(factura,numero_deposito) VALUES ("+campoReciboNumero.getText()+","+campoNumeroFormaPago.getText()+")";        
            resultado = sentencia.executeQuery(consultaSQL);

        } catch (SQLException e) {
            if(e.getSQLState().equals("02000")){ //no_data , una inserción no devuelve nada
            }
            else{       
                if(e.getSQLState().equals("23505")){ //unique violation: llave duplicada
                    JOptionPane.showMessageDialog(null, "\nImposible añadir factura de pago mediante depósito\nUna factura de pago mediante depósito con dicho número de recibo ya ha sido registrada, por favor asegúrese de ingresar correctamete los datos", "Error", JOptionPane.ERROR_MESSAGE); 
                }
                else{
                    JOptionPane.showMessageDialog(null, "\nImposible añadir factura de pago mediante depósito\nError en la base de datos", "Error", JOptionPane.ERROR_MESSAGE);
                    e.printStackTrace();
                    conexion = null;
                }
            }
        }
        finally {
            if (resultado != null) {
                try {
                    resultado.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (sentencia != null) {
                try {
                    sentencia.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (conexion != null) {
                try {
                    conexion.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
    
    private void agregarFacturaTarjeta(){
        Connection conexion=null;
        Statement sentencia=null;
        ResultSet resultado=null;
        
        try {
            Class.forName("org.postgresql.Driver");
        }catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        try{
            conexion = DriverManager.getConnection(cadenaConexion);
            sentencia = conexion.createStatement();
            String consultaSQL="insert into factura_tarjeta(factura,numero_voucher) VALUES ("+campoReciboNumero.getText()+","+campoNumeroFormaPago.getText()+")";        
            resultado = sentencia.executeQuery(consultaSQL);

        } catch (SQLException e) {
            if(e.getSQLState().equals("02000")){ //no_data , una inserción no devuelve nada
            }
            else{       
                if(e.getSQLState().equals("23505")){ //unique violation: llave duplicada
                    JOptionPane.showMessageDialog(null, "\nImposible añadir factura de pago mediante tarjeta de crédito\nUna factura de pago mediante tarjeta de crédito con dicho número de recibo ya ha sido registrada, por favor asegúrese de ingresar correctamete los datos", "Error", JOptionPane.ERROR_MESSAGE); 
                }
                else{
                    JOptionPane.showMessageDialog(null, "\nImposible añadir factura de pago mediante tarjeta de crédito\nError en la base de datos", "Error", JOptionPane.ERROR_MESSAGE);
                    e.printStackTrace();
                    conexion = null;
                }
            }
        }
        finally {
            if (resultado != null) {
                try {
                    resultado.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (sentencia != null) {
                try {
                    sentencia.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (conexion != null) {
                try {
                    conexion.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
    
    public int cargarTipoLineaDetalleEstudiantePendiente(){
        if(!campoEstudiante.getText().equals("")){//quitar este mis filtro en los metodos de abajo
            if(unaVezListenerCalendar==0){
                int valor=efectuoAbonos();
                if(valor==0||valor==1){//valor 0 = no efectuó abonos // valor 1== efectuó abonos
                    cargarLineaDetalleEstudiantePendiente();
                    calculoMontoTotal(valor);
                    unaVezListenerCalendar=1;
                    if(valor==1){
                        return 1;
                    }
                    else{
                        return 0;
                    }
                }
            }
        }
        return 2;
    }
        
    public void setUnaVezListenerCalendar(){
        unaVezListenerCalendar=0;
    }
    
    
    private String ultimoSaldoEstudiante(){
        
        Connection conexion=null;
        Statement sentencia=null;
        ResultSet resultado=null;
        
        try {
            Class.forName("org.postgresql.Driver");
        }catch (ClassNotFoundException e) {
            e.printStackTrace();
        } 
        try{ 
            conexion = DriverManager.getConnection(cadenaConexion);
            sentencia = conexion.createStatement();
            String consultaSQL="select saldo from factura where estudiante='"+estSelec1+"' and anio="+campoAnioFactura.getYear()+" and mes="+campoMesFactura.getMonth()+" order by fecha desc";
            resultado = sentencia.executeQuery(consultaSQL);
            while(resultado.next()){
                return resultado.getString("saldo");
            } 
                                
            } catch (SQLException e) {
                JOptionPane.showMessageDialog(this, "\n Imposible determinar si el estudiante ha realizado abonos de los servicios del mes del año especificado\n Error en la base de datos", "Error", JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
                conexion = null;
            }
            finally {
                if (resultado != null) {
                    try {
                        resultado.close();
                    } catch (Exception e) {
                    e.printStackTrace();
                    }
                }
                if (sentencia != null) {
                    try {
                        sentencia.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                if (conexion != null) {
                    try {
                        conexion.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        
        return "";
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(VentanaModuloFacturacion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(VentanaModuloFacturacion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(VentanaModuloFacturacion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(VentanaModuloFacturacion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VentanaModuloFacturacion().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel astEstudiante;
    private javax.swing.JLabel astEstudiante1;
    private javax.swing.JLabel astEstudiante2;
    private javax.swing.JLabel astEstudiante3;
    private javax.swing.JLabel astFormaPago;
    private javax.swing.JLabel astFormaPago1;
    private javax.swing.JLabel astFormaPago2;
    private javax.swing.JLabel astFormaPago3;
    private javax.swing.JLabel astPagoInicial;
    private javax.swing.JLabel astPagoInicial1;
    private javax.swing.JLabel astPeriodo;
    private javax.swing.JLabel astPeriodo1;
    private javax.swing.JLabel astRecibido;
    private javax.swing.JLabel astRecibido1;
    private javax.swing.JLabel astReciboNumero;
    private javax.swing.JLabel astReciboNumero1;
    private javax.swing.JButton btnAgregarFacturar;
    private javax.swing.JButton btnAgregarFacturar1;
    private javax.swing.JButton btnAyuda;
    private javax.swing.JButton btnAyuda1;
    private javax.swing.JButton btnCancelarFacturar;
    private javax.swing.JButton btnCancelarFacturar1;
    private javax.swing.JButton btnNuevaFactura;
    private javax.swing.JButton btnNuevaFactura1;
    private javax.swing.JButton btnSeleccionarEst;
    private javax.swing.JButton btnSeleccionarEst1;
    private javax.swing.JComboBox cajaFormaPago;
    private javax.swing.JComboBox cajaFormaPago1;
    private com.toedter.calendar.JYearChooser campoAnioFactura;
    private com.toedter.calendar.JYearChooser campoAnioFactura1;
    private javax.swing.JLabel campoEstudiante;
    private javax.swing.JLabel campoEstudiante1;
    private javax.swing.JLabel campoFecha;
    private javax.swing.JLabel campoFecha1;
    private javax.swing.JTextField campoHora;
    private javax.swing.JTextField campoHora1;
    private com.toedter.calendar.JMonthChooser campoMesFactura;
    private com.toedter.calendar.JMonthChooser campoMesFactura1;
    private javax.swing.JTextField campoNumeroFormaPago;
    private javax.swing.JTextField campoNumeroFormaPago1;
    private javax.swing.JTextField campoPagoInicial;
    private javax.swing.JTextField campoPagoInicial1;
    private javax.swing.JLabel campoRebajoTotalDescuentos;
    private javax.swing.JLabel campoRebajoTotalDescuentos1;
    private javax.swing.JTextField campoRecibido;
    private javax.swing.JTextField campoRecibido1;
    private javax.swing.JTextField campoReciboNumero;
    private javax.swing.JTextField campoReciboNumero1;
    private javax.swing.JLabel campoSaldo;
    private javax.swing.JLabel campoSaldo1;
    private javax.swing.JLabel campoSumaTotal;
    private javax.swing.JLabel campoSumaTotal1;
    private javax.swing.JLabel campoTotalReal;
    private javax.swing.JLabel campoTotalReal1;
    private javax.swing.JLabel estudiante;
    private javax.swing.JLabel estudiante1;
    private javax.swing.JLabel fecha;
    private javax.swing.JLabel fecha1;
    private javax.swing.JLabel formaPago;
    private javax.swing.JLabel formaPago1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel pagoInicial;
    private javax.swing.JLabel pagoInicial1;
    private org.edisoncor.gui.panel.PanelImage panelAnularFactura;
    private javax.swing.JPanel panelCamposFactura;
    private javax.swing.JPanel panelCamposFactura1;
    private javax.swing.JPanel panelCobros;
    private javax.swing.JPanel panelCobros1;
    private javax.swing.JPanel panelCobros2;
    private javax.swing.JPanel panelCobros3;
    private org.edisoncor.gui.panel.PanelImage panelGenerarFactura;
    private org.edisoncor.gui.panel.PanelImage panelImagenFacturacion;
    private org.edisoncor.gui.panel.PanelImage panelImagenFacturacion2;
    private javax.swing.JPanel panelManejoFactura;
    private javax.swing.JPanel panelManejoFactura1;
    private javax.swing.JTabbedPane panelOpciones;
    private javax.swing.JLabel rebajoTotalDescuentos;
    private javax.swing.JLabel rebajoTotalDescuentos1;
    private javax.swing.JLabel recibido;
    private javax.swing.JLabel recibido1;
    private javax.swing.JLabel reciboNumero;
    private javax.swing.JLabel reciboNumero1;
    private javax.swing.JLabel saldo;
    private javax.swing.JLabel saldo1;
    private javax.swing.JScrollPane scrollServicios;
    private javax.swing.JScrollPane scrollServicios1;
    private javax.swing.JLabel sumaTotal;
    private javax.swing.JLabel sumaTotal1;
    private javax.swing.JTable tablaServicios;
    private javax.swing.JTable tablaServicios1;
    private javax.swing.JLabel totalReal;
    private javax.swing.JLabel totalReal1;
    // End of variables declaration//GEN-END:variables
    private String estSelec1;
    private String estSelec2;
    static String cadenaConexion = "jdbc:postgresql://localhost/SMAAMDB?" + "user=postgres&password=root";
    private ArrayList montos;
    private ArrayList descuentos;
    private ArrayList cursos;
    private ArrayList numeros;
    private ArrayList precios;
    private int matricula;
    private int recargo;
    private int unaVezListenerCalendar;
}
